import cv2 #读取格式是BGR
import matplotlib.pyplot as plt
import numpy as np
from partd.utils import frame
from pyarrow.lib import Type_INT32

#读取一个视频
vc =  cv2.VideoCapture('C:/Users/nic/Desktop/opencv/video/tangyuan.mp4')
#检查这个视频能否被打开
if vc.isOpened():
    open,frane = vc.read()
else:
    open = False
#要取读取每一帧的图像，连起来就是视频
while open:
    ret,frame = vc.read()
    if frame is None:
        break
    if ret == True:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #把三颜色图转化为灰度图
        cv2.imshow('result',gray)
        if cv2.waitKey(10) & 0xFF ==27:
            break
vc.release()
cv2.destroyAllWindows()

